<?php
if(!defined('ADMIN')){
	exit('Access Denied');
}

if($_POST['sub']!=''){

    $id=empty($_POST['id'])?0:(int)$_POST['id'];
	unset($_POST['id']);
	unset($_POST['sub']);
    
    if(trim($_POST['adminname'])==""){
        jumpajax('300','用户名不能为空！','');
    }   
        
    $data=array('adminname'=>$_POST['adminname'],'role'=>$_POST["role"],"email"=>$_POST["email"],"qq"=>$_POST["qq"],"mobile"=>$_POST["mobile"],"shop_id"=>$_POST["shop_id"]);
    $pwd=trim($_POST["adminpass"]);
    if(!empty($pwd)){
        $data["adminpass"]=md5(md5(EZKEY.$pwd).EZKEY); 
    }
	
 	if($id==0){
            
        if(trim($_POST['adminpass'])==""){
            jumpajax('300','登录密码不能为空！','');
        }  
     	  
        $data["addtime"]=time();
	    $id=$ezhand->insert(MOD,$data);
		jumpajax('200','保存成功','','closeCurrent');
	}
	else{
	    $ezhand->update(MOD,$data,'id="'.$id.'"');
		jumpajax('200','修改成功','','closeCurrent');
	}
}
else{
        $shoplisttemp=$ezhand->get_chefbyid("shopping3_chef");
        $shoplist=array("0"=>"请选择");
        foreach($shoplisttemp as $val){
            $id=$val["id"];
            $shoplist[$id]=$val["name"];  

        }
	$id=empty($_GET['id'])?0:(int)$_GET['id'];
	
    if($id==0){
	    $row=array();
		$role_menu_arr=array();
	}
	else{
	    $row=$ezhand->select(MOD,'*','id="'.$id.'"');
	}
}
?>